
Product
Go Support Is Now Generally Available
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.
jss-plugin-default-unit
Advanced tools
JSS plugin that adds default custom unit to numeric values where needed
The jss-plugin-default-unit npm package is a plugin for JSS (JavaScript Style Sheets) that automatically adds units to numeric values in style objects. This is particularly useful when working with CSS in JS, as it simplifies the process of defining styles by allowing developers to omit units for properties that require them, with the plugin automatically appending the appropriate unit based on the property.
Automatic unit appending
Automatically appends 'px' to numeric values for properties that typically require a pixel unit, while leaving unitless values as is for properties that do not require units.
{
container: {
width: 100, // becomes '100px' automatically
opacity: 0.5 // remains unitless as expected
}
}
Customizable unit mapping
Allows customization of the units appended to specific properties, enabling developers to specify alternative units like 'em' or 'rem' for properties like 'line-height' and 'font-size'.
jss.use(defaultUnit({
'line-height': 'em',
'font-size': 'rem'
}));
Styled-components is a library for styling React components using tagged template literals. It supports automatic unit appending in a similar way to jss-plugin-default-unit but is more focused on component-level styling with a CSS-in-JS approach.
Glamor is a CSS-in-JS library that allows for styling components with JavaScript. It offers similar functionality to jss-plugin-default-unit in terms of automatically appending units to styles defined in JavaScript, but it provides a different API and approach to styling.
JSS plugin that adds default custom unit to numeric values where needed
See our website jss-plugin-default-unit for more information.
Using npm:
npm install jss-plugin-default-unit
or using yarn:
yarn add jss-plugin-default-unit
FAQs
JSS plugin that adds default custom unit to numeric values where needed
The npm package jss-plugin-default-unit receives a total of 1,589,609 weekly downloads. As such, jss-plugin-default-unit popularity was classified as popular.
We found that jss-plugin-default-unit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.
Security News
vlt adds real-time security selectors powered by Socket, enabling developers to query and analyze package risks directly in their dependency graph.
Security News
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.